package com.changgou.order.listener;

import com.changgou.order.service.OrderService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.web.server.ConditionalOnManagementPort;
import org.springframework.stereotype.Component;

/**
 * @author zero
 * @date 2020/7/15
 */

@Component
public class OrderTimeOutListener {


    @Autowired
    private OrderService orderService;

    @RabbitListener(queues = "queue.ordertimeout")
    public void receiveCloseOrderMessage(String message){

        System.out.println("接收延迟队列的消息:" + message);

        try {
            orderService.closeOrder(message);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
